﻿using System.Collections.ObjectModel;
using System.Windows.Controls;

namespace ibba.src.noriskbo
{
    public class ErrorCollection : ObservableCollection<ValidationError>
    {
        public void ValidationError(ValidationErrorEventArgs e)
        {
            switch (e.Action)
            {
                case ValidationErrorEventAction.Added:
                    if (!this.Contains(e.Error))
                    {
                        this.Add(e.Error);
                    }
                    break;

                case ValidationErrorEventAction.Removed:
                    this.Remove(e.Error);
                    break;

                default:
                    break;
            }
        }

        public bool HasError
        {
            get { return this.Count > 0; }
        }
    }


}
